<!--
/**
* Author: zyf
* Date: 2021-11-30 14:02
* Desc: mallCouponDetail 核销详情
*/
-->
<template>
  <view class="mcd-page">
    <template v-if="fromPage === 'history'">
      <gc-cell
        class="mb5"
        label="核销时间"
        :value="info.verificationTime || '--'"
      />
      <gc-cell class="mb5" label="订单号" :value="info.orderNo || '--'" />
      <gc-cell class="mb5" label="手机号" :value="info.mobile || '--'" />
      <gc-cell
        class="mb5"
        label="核销方式"
        :value="info.verificationType || '--'"
      />
      <gc-cell
        v-if="info.verificationUserName"
        class="mb5"
        label="核销人"
        :value="info.verificationUserName || '--'"
      />
    </template>
    <template v-else>
      <view class="mcd-page__tip">请出示本页面给店员，领取核销商品。</view>
      <view class="fs15 b mb10">{{ info.businessName || '--' }}</view>
      <view class="fs15 mb10"
        >核销时间: {{ info.verificationTime || '--' }}</view
      >
    </template>
    <view class="fs15 b mb10 mt25 mb5">本次核销商品如下</view>
    <view
      class="mcd-page__item"
      v-for="(item, index) in info.codeDetail"
      :key="index"
    >
      <view class="mb5">{{ item.name }}</view>
      <!-- #ifndef MP-TOUTIAO -->
      <view class="mcd-page__desc">券码：{{ item.code }}</view>
      <!-- #endif -->
    </view>
  </view>
</template>

<script>
  import GcCell from './components/GcCell.vue'
  export default {
    name: 'verification',
    components: { GcCell },
    data() {
      return {
        info: {
          codeDetail: []
        },
        id: '',
        fromPage: ''
      }
    },
    onLoad(options) {
      console.log(options, 'options')
      this.id = options.id
      this.fromPage = options.fromPage || ''
      this.$nextTick(() => {
        if (this.fromPage === 'history') {
          uni.setNavigationBarTitle({ title: '核销详情' })
        } else {
          uni.setNavigationBarTitle({ title: '核销成功' })
        }
        this.init()
      })
    },
    methods: {
      // 初始化方法
      init() {
        this.getInfo()
      },
      getInfo() {
        this.$msg.loading()
        uni.$api.coupon.getVerificationDetail({ id: this.id }).then((res) => {
          this.$msg.hideLoading()
          this.info = res
        })
      }
    }
  }
</script>
<style lang="scss" scoped>
  .mcd-page {
    background: #fff;
    padding: 33upx;
    &__desc {
      font-size: 26upx;
      color: #888;
    }
    &__item {
      border: 1px solid #e2e2e2;
      border-radius: 10upx;
      padding: 20upx 20upx;
      margin-top: 14upx;
    }
    &__tip {
      color: #ffae00;
      margin-bottom: 24upx;
    }
    /deep/ .gc-cell {
      font-size: 28upx;
      color: #222;
    }
  }
</style>
